/**
 * @description 指令下达
 * @author wangjianjun
 */

import React, { PureComponent } from 'react';
import { DATA_ENTRY, FormGroup, PrimaryC, PrimaryGhostC, TableC } from '../../../../comps';
import dictionaryConfig from '../../../../utils/dictionaryConfig';
import { fixedNum } from '../../../../utils/utils';
import investmentTypeData from '../../../../utils/enumeratedValues/investmentType';
import { isZiGuanEvir, calculateFee, uniqueKey } from '../../../../utils/commonFunc';
import moment from 'moment';
import { Form } from '@ant-design/compatible';
import '@ant-design/compatible/assets/index.css';
import { message, Modal } from 'antd';
import { connect } from 'dva';
import 'moment/locale/zh-cn';

@Form.create()
@connect(({ exchangeAgreement, trailM, isAccountConfiguredM, bondTrade, buybackOrder, userM: user, loading, portfolioTrialAddM }) => ({
  exchangeAgreement,
  trailM,
  isAccountConfiguredM,
  bondTrade,
  buybackOrder,
  errorSetMsg: isAccountConfiguredM.msg,
  user,
  loading,
  portfolioTrialAddM,
}))
export default class InstructionSend extends PureComponent {
  constructor(props) {
    super(props);
    this.timeChange = null;
    this.state = {
      formItem: {},
      bjlxData: dictionaryConfig.exchange.optionalQuotationType[0], //报价类型数据--给指令用
      bjlxData2: dictionaryConfig.exchange.optionalQuotationType[4], //报价类型数据--给簿记用
      agreeCodeRules: false, //约定号是否必填
      exchangeDisabled: true, //控制交易所disable
      quotationTypeDisabled: true, //控制报价类型disable
      settlementDateDisabled: true, //控制到期结算日disable
      occupationDaysDisabled: true, //控制实际占款天数disable
      disabled: true, //控制全局disable
      productGroupDisabled: false,
      selfDisabledControl: {
        //可选报价类型可编辑字段
        productId: false, //产品
        portfolioId: false, //组合
        exchange: false, //交易所
        quotationType: false, //报价类型
        orderSide: false, //委托方向，所有类型都可以修改
        agreementNumber: false, //约定号
        repurchaseDays: false, //回购期限
        repoRate: false, //回购利率
        firstSettlemenDate: false, //首期结算日
        counterParty: false, //交易对手
        counterPartyCode: false, //交易对手编号
        counterPartyper: false, //对手交易员
        addPledge: false, //新增质押券
        editPledge: false, //编辑质押券
        deletePledge: false, //删除质押券
        position: false, //持仓可点回填
      },
      pid: '',
      Share: 12,
      productShare: 24,
      productMargin: '10px',
      btnLoading: false,
      onRef: () => {}, // 本组件的引用
      isCanOrder: true, //是否可以下达 默认可以下达
      trailColumns: [], //试算结果列表
      trailDataSource: [], //试算结果数据
      trailModel: false, //试算模态框
      productCode: undefined, //产品code
      portfolioCode: undefined, //组合code
      isZiGuan: false,
      feeData: {
        //费用自动计算条件
        productId: undefined,
        portfolioid: undefined,
        exchangecode: '101',
        sectype: 'hg',
        sectypeii: 'xyshg',
        orderside: undefined,
        timeLimit: undefined,
        pledgedbondsamount: undefined,
        price: undefined,
      },
      uid: '',
    };
  }

  componentDidMount() {
    // 父组件对本组件的引用
    this.props.edit !== false ? this.props.onRef(this) : null; // 详情页面无需指令操作
    let temp = isZiGuanEvir();
    let isZiGuan = !!temp; // 判断该页面是在资管被引入的，还是maat
    this.setState({
      isZiGuan,
    });

    if (this.props.tradeInfo) {
      //获取持仓分析信息
      this.props.dispatch({
        type: 'exchangeAgreement/getPosition',
        payload: {
          portfolioId: this.props.tradeInfo.trade13.portfolioId,
          exchangeCode: this.props.tradeInfo.trade13.exchange,
          currentPage: 1,
          numInPage: 500,
        },
        callback: (data) => {
          this.props.getTableData(data, '1');
        },
      });
      //获取在途回购信息
      this.props.dispatch({
        type: 'exchangeAgreement/getBookBuyBack',
        payload: {
          portfolioId: this.props.tradeInfo.trade13.portfolioId,
          id: this.props.tradeInfo.id,
          currentPage: 1,
          numInPage: 500,
        },
        callback: (data) => {
          //调用父方法，抛出data
          this.props.getTableData(data, '2');
        },
      });

      this.setState({
        productGroupDisabled: true,
      });
    }
    const uid = uniqueKey();
    uid.then((r) => {
      this.setState({ uid: r });
    });
  }

  UNSAFE_componentWillReceiveProps(nextProps) {
    if (nextProps.initValue && this.timeChange == null) {
      this.timeChange = new Date().getTime();
      if ((nextProps.initValue.orderSide == '1' || nextProps.initValue.orderSide == '融券回购') && nextProps.initValue.orderCategory != '11' && this.props.edit != false) {
        nextProps.initValue.orderCategory = Number(nextProps.initValue.orderCategory) - 5 + '';
      }
      this.setState({
        formItem: nextProps.initValue,
        productId: nextProps.initValue.productId,
        portfolioId: nextProps.initValue.portfolioId,
      });
    }
    if (nextProps.edit == false) {
      this.setState({
        productGroupDisabled: true,
        Share: 8,
        productShare: 16,
        productMargin: '0px',
      });
    }
  }

  componentWillUnmount() {
    //页面销毁 将全局 portfolioId 清空

    if (this.props.tradeBook == '0') {
      this.props.dispatch({
        type: 'buybackOrder/save',
        payload: {
          portfolioId: null,
        },
      });
    }
  }

  //费用自动计算
  changeFee = (type, data) => {
    const {
      form: { setFieldsValue },
    } = this.formGroupThis.props;
    if (this.props.edit == false) return; //详情不计算
    setTimeout(() => {
      if (data == undefined) {
        setFieldsValue({ fee: undefined });
        if (type == 'productId') {
          this.setState({ feeData: { ...this.state.feeData, productId: undefined, portfolioid: undefined } });
        } else {
          this.setState({ feeData: { ...this.state.feeData, [type]: undefined } });
        }
      } else {
        this.setState({ feeData: { ...this.state.feeData, [type]: data } }, () => {
          let fee = calculateFee(this.state.feeData);
          fee.then((r) => {
            setFieldsValue({ fee: r });
          });
        });
      }
    }, 100);
  };

  //点击在途回购代码 指令基本信息回填
  reNewPledgeBondData2 = () => {
    const {
      form: { setFieldsValue, getFieldValue },
    } = this.formGroupThis.props;
    const { reNewPledgeBondData } = this.props;
    this.Company.setSelect(reNewPledgeBondData.counterPartyorg); //设置交易对手的值
    setFieldsValue({
      exchange: reNewPledgeBondData.exchange,
      // quotationType: null, //报价类型不要回填
      orderSide: reNewPledgeBondData.orderSide,
      agreementNumber: null, //约定号不要回填
      repurchaseDays: reNewPledgeBondData.repurchaseDays + '',
      repoRate: reNewPledgeBondData.repoRate,
      firstSettlemenDate: moment(reNewPledgeBondData.firstSettlemenDate),
      settlementDate: moment(reNewPledgeBondData.settlementDate),
      occupationDays: reNewPledgeBondData.occupationDays + '',
      counterParty: reNewPledgeBondData.counterParty,
      counterPartyCode: reNewPledgeBondData.counterPartyCode,
      counterPartyper: reNewPledgeBondData.counterPartyper,
      creator: reNewPledgeBondData.creator,
      investmentType: reNewPledgeBondData.investmentType,
    });
    if (
      getFieldValue('quotationType') != '2' &&
      getFieldValue('quotationType') != '3' &&
      getFieldValue('quotationType') != '4' &&
      getFieldValue('quotationType') != '5' &&
      getFieldValue('quotationType') != '11'
    ) {
      setFieldsValue({
        quotationType: null, //清空报价类型
      });
    }
    this.setState({
      pid: reNewPledgeBondData.idx ? reNewPledgeBondData.idx : '',
    });
    const settlemenDate = moment(reNewPledgeBondData.settlementDate).format('YYYYMMDD');
    if (reNewPledgeBondData.orderSide == '1' || reNewPledgeBondData.orderSide == '融券回购') {
      this.setState({
        agreeCodeRules: true,
      });
    }
    //把交易所 传到期结算日子组件
    this.props.changeExchange(reNewPledgeBondData.exchange);
    //把期结算日 传到期结算日子组件
    this.props.changeSettlementDate(settlemenDate);

    //把天数 传到期结算日子组件
    this.props.changeOccupationDays(reNewPledgeBondData.occupationDays);

    //把回购利率 传到期结算日子组件
    this.props.changeRepoRate(reNewPledgeBondData.repoRate);
    //把报价类型/委托方向 传到期结算日子组件
    this.props.changeQuotationType(getFieldValue('quotationType'), reNewPledgeBondData.orderSide);
    // this.props.changeQuotationType(this.props.tradeBook=='0'?null:reNewPledgeBondData.orderCategory,reNewPledgeBondData.orderSide)

    this.setState({
      disabled: false,
      exchangeDisabled: false,
      quotationTypeDisabled: false,
    });

    //回填数据的时候 控制报价类型下拉内容
    const orderSideValue = reNewPledgeBondData.orderSide;
    const nowDate = moment().format('YYYYMMDD');
    const settlementDateValue = moment(reNewPledgeBondData.settlementDate).format('YYYYMMDD');

    // if ((orderSideValue == '2' || orderSideValue == '融资回购') && this.props.tradeBook == '0') {
    //     if (nowDate == settlementDateValue) {
    //         this.setState({
    //             bjlxData: dictionaryConfig.exchange.optionalQuotationType[1]
    //         })
    //     }
    //     if (nowDate < settlementDateValue) {
    //         this.setState({
    //             bjlxData: dictionaryConfig.exchange.optionalQuotationType[2]
    //         })
    //     }
    //     if (nowDate > settlementDateValue) {
    //         this.setState({
    //             bjlxData: []
    //         })
    //     }
    // }

    // if (orderSideValue == '1' || orderSideValue == '融券回购') {
    //     if (nowDate == settlementDateValue) {
    //         this.setState({
    //             bjlxData: dictionaryConfig.exchange.optionalQuotationType[3]
    //         })
    //     }
    //     if (nowDate < settlementDateValue) {
    //         this.setState({
    //             bjlxData: dictionaryConfig.exchange.optionalQuotationType[2]
    //         })
    //     }
    //     if (nowDate > settlementDateValue) {
    //         this.setState({
    //             bjlxData: []
    //         })
    //     }
    // }
    this.setState({
      bjlxData: dictionaryConfig.exchange.optionalQuotationType[5],
    });

    //指令下达 回填不可编辑
    if (this.props.tradeBook == '0') {
      this.setState({
        disabled: true, //控制全局disable
        exchangeDisabled: true, //控制交易所disable
        settlementDateDisabled: true, //控制到期结算日disable
        occupationDaysDisabled: true, //控制实际占款天数disable
        orderSideDisabled: true,
        agreeCodeRules: true,
        productGroupDisabled: true,
      });
    }

    //如果是蒲计 要回填 产品和组合
    if (this.props.tradeInfo) {
      this.setState({
        productId: reNewPledgeBondData.productId,
        portfolioId: reNewPledgeBondData.portfolioId,
        exchangeDisabled: true,
        quotationTypeDisabled: true,
        orderSideDisabled: true,
      });
    }
  };

  //交易对手搜索
  handleSearch = (value) => {
    if (value) {
      // 获取交易对手全量
      this.props.dispatch({
        type: 'exchangeAgreement/queryCounterparty',
        payload: {
          value: value,
        },
      });
    }
  };

  //切换组合
  groupOnChange = (value) => {
    const {
      form: { resetFields, getFieldValue },
    } = this.formGroupThis.props;
    //相关清空操作
    //清空持仓分析和在途回购信息
    this.props.getTableData({ columns: [], dataSource: [] }, '1');
    this.props.getTableData({ columns: [], dataSource: [] }, '2');
    this.setState({
      pid: '',
    });
    //清空质押券表内容
    this.props.clearPledgeBondInfo();
    if (value) {
      this.props.getLoading('0');
    }
    //清空一些相关的公共参数
    resetFields([
      'exchange',
      'quotationType',
      'orderSide',
      'agreementNumber',
      'repurchaseDays',
      'repoRate',
      'firstSettlemenDate',
      'settlementDate',
      'occupationDays',
      'counterParty',
      'counterPartyCode',
      'counterPartyper',
      'creator',
    ]);

    //促发设置新增按钮disabled
    this.props.changeQuotationType('1');
    this.props.changeSettlementDate(null);
    //指令 下达判断是否有指令配置
    if (this.props.tradeBook == '0') {
      if (value) {
        this.props.dispatch({
          type: 'isAccountConfiguredM/queryIsAccountConfigured',
          payload: {
            portId: value.key,
          },
          callback: (data) => {
            if (data.result) {
              this.setState({
                isCanOrder: true,
              });
            } else {
              this.setState({
                isCanOrder: false,
              });
              message.warning(data.msg);
            }
          },
        });
      } else {
        this.setState({
          isCanOrder: false,
        });
      }
    }
    if (value) {
      //获取资金信息
      let newValue = value ? value.key : value;
      this.props.getPortfolioId(newValue); //向父组件抛出组合id，用于切换tab请求资金
      //调用父方法，触发loading
      //获取持仓分析信息
      this.props.dispatch({
        type: 'exchangeAgreement/getPosition',
        payload: {
          portfolioId: newValue,
          exchangeCode: getFieldValue('exchange'),
          currentPage: 1,
          numInPage: 500,
        },
        callback: (data) => {
          //调用父方法，抛出data
          this.props.getTableData(data, '1');
        },
      });
      //获取在途回购信息
      this.props.dispatch({
        type: 'exchangeAgreement/getBuyBack',
        payload: {
          portfolioId: newValue,
          currentPage: 1,
          method: this.props.tradeBook == '1' ? '0' : '1',
          numInPage: 500,
        },
        callback: (data) => {
          //调用父方法，抛出data
          this.props.getTableData(data, '2');
        },
      });

      //解开disabled
      this.setState({
        exchangeDisabled: false,
        quotationTypeDisabled: false,
      });
    } else {
      //设置为disabled
      this.props.getPortfolioId(undefined); //组合id为undefined 也抛出清空资金
      this.setState({
        disabled: true,
        exchangeDisabled: true,
        quotationTypeDisabled: true,
      });
    }
    this.setState({
      disabled: false,
    });
  };

  //切换交易所
  jysOnChange = (e) => {
    const {
      form: { getFieldValue, resetFields },
    } = this.formGroupThis.props;
    //不同的交易所 切换不同的报价类型
    if (e == '101') {
      this.setState({
        bjlxData: dictionaryConfig.exchange.shanghaiExchange,
      });
    }
    if (e == '105') {
      this.setState({
        bjlxData: dictionaryConfig.exchange.shenzhenExchange,
      });
    }
    this.props.changeExchange(e);
    // 清空报价类型，交易方向
    resetFields(['quotationType', 'orderSide']);
    // 调用父方法，触发loading
    this.props.getLoading('1');
    // 重新获取持仓分析数据
    this.props.dispatch({
      type: 'exchangeAgreement/getPosition',
      payload: {
        portfolioId: getFieldValue('portfolioId'),
        exchange: getFieldValue('exchange'),
        currentPage: 1,
        numInPage: 9,
      },
      callback: (data) => {
        //调用父方法，抛出data
        this.props.getTableData(data, '1');
      },
    });
  };

  //切换报价类型
  bjlxOnChange = (e) => {
    const { dispatch } = this.props;
    const {
      form: { getFieldValue, setFieldsValue },
    } = this.formGroupThis.props;
    const disabledControl = dictionaryConfig.exchange.disabledControl;
    let orderSideValue = getFieldValue('orderSide');
    let eValue = Number(e);
    let data2 = null;
    //切换报价类型，如果是融券回购，要转换。
    if (orderSideValue == 1 || orderSideValue == '融券回购') {
      eValue = eValue + 5;
      data2 = disabledControl.find((item) => item.value == eValue);
    } else {
      data2 = disabledControl.find((item) => item.value == eValue);
    }

    //配置报价类型可编辑字段
    if (data2 && this.props.tradeBook == '0') {
      this.setState({
        selfDisabledControl: data2,
      });
    }

    if (eValue == '1') {
      this.setState({
        orderSideDisabled: false,
      });
    }

    let data =
      getFieldValue('exchange') == '101'
        ? dictionaryConfig.exchange.shanghaiExchange.find((item) => item.value == e)
        : dictionaryConfig.exchange.shenzhenExchange.find((item) => item.value == e);
    if (data) {
      this.setState({
        //设置委托方向disable
        // :!(data.modifyOrderSide),
        agreeCodeRules: data.agreeCode, //设置约定号是否必填
      });
      //控制质押券部分 的原质押券代码字段
      this.props.changeQuotationType(e);
    }

    if (orderSideValue == 1 || orderSideValue == '融券回购') {
      this.setState({
        agreeCodeRules: true,
      });
    }
    //计算实际占款天数和到期结算日
    if (data && data.calculation == true) {
      if (getFieldValue('repurchaseDays')) {
        const day = moment(getFieldValue('firstSettlemenDate'));
        let firstSettlemenDate = day.add(0, 'days').format('YYYY-MM-DD');
        dispatch({
          type: 'exchangeAgreement/calculation',
          payload: {
            repurchaseDays: getFieldValue('repurchaseDays'),
            firstSettlemenDate: firstSettlemenDate,
          },
          callback: (data) => {
            setFieldsValue({
              settlementDate: moment(data.settlementDate),
              occupationDays: data.occupationDays,
            });
            this.props.changeSettlementDate(data.settlementDate); //到期结算日传到子组件
            this.props.changeOccupationDays(data.occupationDays);
          },
        });
      }
    }
  };

  //委托方向改变
  wtfxOnChange = (e) => {
    const {
      form: { getFieldValue },
    } = this.formGroupThis.props;
    let quotationTypeValue = getFieldValue('quotationType');
    const disabledControl = dictionaryConfig.exchange.disabledControl;
    //如果切换成融券回购，切换状态
    if (e == 1 || e == '融券回购') {
      if (quotationTypeValue) {
        let Number1 = Number(quotationTypeValue) + 5;
        let data2 = disabledControl.find((item) => item.value == Number1);

        if (data2 && this.props.tradeBook == '0') {
          this.setState({
            selfDisabledControl: data2,
          });
        }
      }
      //逆回购约定号必填
      this.setState({
        agreeCodeRules: true,
      });
    } else {
      this.setState({
        agreeCodeRules: false,
      });
      if (quotationTypeValue) {
        let Number1 = Number(quotationTypeValue);
        let data2 = disabledControl.find((item) => item.value == Number1);

        if (data2 && this.props.tradeBook == '0') {
          this.setState({
            selfDisabledControl: data2,
          });
        }
      }
    }

    //清空质押券表内容
    this.setState({
      pid: '',
    });

    this.props.clearPledgeBondInfo();

    //正回购和负回购传递给质押表
    this.props.changeOrderSide(e);
  };

  //回购期限改变
  hgqxOnChange = (e) => {
    const { dispatch } = this.props;
    const {
      form: { getFieldValue, setFieldsValue },
    } = this.formGroupThis.props;
    let data =
      getFieldValue('exchange') == '101'
        ? dictionaryConfig.exchange.shanghaiExchange.find((item) => item.value == getFieldValue('quotationType'))
        : dictionaryConfig.exchange.shenzhenExchange.find((item) => item.key == getFieldValue('quotationType'));
    const reg = /^([1-9]|[1-9][0-9]|[1-2][0-9][0-9]|[3][0-5][0-9]|(360|361|363|362|364|365))$/;
    const r = e.target.value.match(reg);
    if (r == null) {
      return;
    }
    this.changeFee('timeLimit', e.target.value);
    const day = moment(getFieldValue('firstSettlemenDate'));
    let firstSettlemenDate = day.add(0, 'days').format('YYYY-MM-DD');
    if (data && data.calculation == true) {
      dispatch({
        type: 'exchangeAgreement/calculation',
        payload: {
          repurchaseDays: e.target.value,
          firstSettlemenDate: firstSettlemenDate,
        },
        callback: (data) => {
          setFieldsValue({
            settlementDate: moment(data.settlementDate),
            occupationDays: data.occupationDays,
          });
          this.props.changeSettlementDate(data.settlementDate);
          this.props.changeOccupationDays(data.occupationDays);
        },
      });
    }
  };

  //回购利率改变
  changeRepoRate = (e) => {
    if (e && e > 0) {
      this.props.changeRepoRate(e);
    } else {
      this.props.changeRepoRate(null);
    }
  };

  //首期结算日改变
  sqjsrOnChange = (e) => {
    const { dispatch } = this.props;
    const {
      form: { getFieldValue, setFieldsValue },
    } = this.formGroupThis.props;
    let data =
      getFieldValue('exchange') == '101'
        ? dictionaryConfig.exchange.shanghaiExchange.find((item) => item.value == getFieldValue('quotationType'))
        : dictionaryConfig.exchange.shenzhenExchange.find((item) => item.key == getFieldValue('quotationType'));
    const firstSettlemenDate = moment(e).format('YYYY-MM-DD');
    const repurchaseDays = getFieldValue('repurchaseDays');
    if (data && data.calculation == true) {
      if (repurchaseDays) {
        dispatch({
          type: 'exchangeAgreement/calculation',
          payload: {
            repurchaseDays: repurchaseDays,
            firstSettlemenDate: firstSettlemenDate,
          },
          callback: (data) => {
            setFieldsValue({
              settlementDate: moment(data.settlementDate),
              occupationDays: data.occupationDays,
            });
            this.props.changeSettlementDate(data.settlementDate);
            this.props.changeOccupationDays(data.occupationDays);
          },
        });
      }
    }
  };

  //判断有没有质押，有质押券修改到期结算日时提示用户
  remind = () => {
    if (this.props.childData.length > 0 && this.props.tradeBook == '0') {
      message.warning('请确认当前质押券到期日要大于 "所有质押券信息表里质押券的回购到期结算日"!');
    }
  };

  //到期结算日改变
  dqjsrOnChange = (e) => {
    const {
      form: { getFieldValue },
    } = this.formGroupThis.props;
    const settlemenDate = moment(e).format('YYYYMMDD');
    this.props.changeSettlementDate(settlemenDate);

    if (getFieldValue('orderSide') == '融资回购' || getFieldValue('orderSide') == '2') {
      this.props.getPledgeBondInfo('2');
    }
  };

  saveInstructionSend = (confirmType) => {
    const { user, dispatch } = this.props;
    const {
      form: { validateFields, resetFields },
    } = this.formGroupThis.props;
    if (!this.state.isCanOrder && this.props.tradeBook == '0') {
      //在点击“下达”时，若标记指示未配置指令，则提示用户“该组合为配置指令，无法下发指令。
      message.warning(this.props.errorSetMsg);
      return;
    }
    let tempObj;
    validateFields(
      [
        'productId',
        'portfolioId',
        'exchange',
        'quotationType',
        'orderSide',
        'agreementNumber',
        'repurchaseDays',
        'repoRate',
        'firstSettlemenDate',
        'settlementDate',
        'occupationDays',
        'counterParty',
        'counterPartyCode',
        'counterPartyper',
        'creator',
        'investmentType',
        'fee',
        'describe',
      ],
      (err, fieldsValue) => {
        if (err) return;
        if (this.props.childData == undefined || this.props.childData == null || this.props.childData.length == 0) {
          message.warning('请添加质押券信息');
          return;
        }
        let orderSide = '';
        if (fieldsValue.orderSide == '融资回购' || fieldsValue.orderSide == '2') {
          orderSide = '2';
          let endDate = moment(fieldsValue.settlementDate).format('YYYYMMDD');

          let flag = null;
          this.props.childData.map((item) => {
            if (item && item.dueDate && endDate >= moment(item.dueDate).format('YYYYMMDD') && this.props.tradeBook == '0') {
              message.warning('请确认当前质押券到期日要大于 "所有质押券信息表里质押券的回购到期结算日"!');

              flag = 1;
            }
          });

          if (flag == 1) {
            return;
          }
          //这边日期
        }
        if (fieldsValue.orderSide == '融券回购' || fieldsValue.orderSide == '1') {
          orderSide = '1';
        }
        if (moment(fieldsValue.firstSettlemenDate).format('YYYYMMDD') >= moment(fieldsValue.settlementDate).format('YYYYMMDD') && this.props.tradeBook == '0') {
          message.warning('请设置到期结算日晚于首期结算日');
          return;
        }

        // 指令下达时判断委托方向和可选报价类型是否匹配，指令下达时带确认的报价类型，需要转换
        let newOrderCategory1 = orderSide == '1' && fieldsValue.quotationType != '11' ? Number(fieldsValue.quotationType) + 5 + '' : fieldsValue.quotationType;
        const value = {
          pid: this.state.pid,
          portfolioId: fieldsValue.portfolioId,
          portfolioInfoId: fieldsValue.portfolioId,
          productId: fieldsValue.productId,
          type: 13,
          userId: localStorage.getItem('antd-pro-userId'),
          userName: user.currentUser.name,
          uid: this.state.uid,
          trade13: {
            portfolioId: fieldsValue.portfolioId,
            productId: fieldsValue.productId,
            exchange: fieldsValue.exchange,
            orderCategory: newOrderCategory1,
            orderSide: orderSide,
            agreeCode: fieldsValue.agreementNumber,
            repurchaseDays: Number(fieldsValue.repurchaseDays),
            repoRate: fieldsValue.repoRate,
            firstSettlemenDate: moment(fieldsValue.firstSettlemenDate).format('YYYY-MM-DD'),
            settlementDate: moment(fieldsValue.settlementDate).format('YYYY-MM-DD'),
            occupationDays: Number(fieldsValue.occupationDays),
            counterParty: fieldsValue.counterParty,
            counterPartyCode: fieldsValue.counterPartyCode,
            counterPartyper: fieldsValue.counterPartyper,
            creator: fieldsValue.creator,
            pledgeVo: [...this.props.childData],
            investmentType: fieldsValue.investmentType,
            fee: 0, // 费用计算逻辑未完全梳理清楚，后续用户有真正需求时再添加费用计算相关逻辑
            describe: fieldsValue.describe,
          },
        };
        if (this.props.tradeBook == '1') {
          let url = this.props.type == 11 ? 'portfolioTrialAddM/exchangeAgreementSave' : 'exchangeAgreement/saveInstruction2';
          //触发loading
          this.setState({
            btnLoading: true,
          });

          if (this.props.tradeInfo) {
            value.id = this.props.tradeInfo.id;
          }

          dispatch({
            type: url,
            payload: {
              method: '0',
              ...value,
            },
          }).then((res) => {
            //解除loading
            this.setState({
              btnLoading: false,
            });
            const uid = uniqueKey();
            uid.then((r) => {
              this.setState({ uid: r });
            });
            if (res && res.success) {
              this.props.rehandleSearch2();
              this.setState({
                pid: '',
                productGroupDisabled: false,
                selfDisabledControl: {
                  //可选报价类型可编辑字段
                  productId: false, //产品
                  portfolioId: false, //组合
                  exchange: false, //交易所
                  quotationType: false, //报价类型
                  orderSide: false, //委托方向，所有类型都可以修改
                  agreementNumber: false, //约定号
                  repurchaseDays: false, //回购期限
                  repoRate: false, //回购利率
                  firstSettlemenDate: false, //首期结算日
                  counterParty: false, //交易对手
                  counterPartyCode: false, //交易对手编号
                  counterPartyper: false, //对手交易员
                  addPledge: false, //新增质押券
                  editPledge: false, //编辑质押券
                  deletePledge: false, //删除质押券
                  position: false, //持仓可点回填
                },
                bjlxData: dictionaryConfig.exchange.optionalQuotationType[0],
              });

              //清空资金
              this.props.getPortfolioId(undefined); //组合id为undefined 也抛出清空资金

              //清空持仓分析和在途回购信息
              this.props.getTableData({ columns: [], dataSource: [] }, '1');
              this.props.getTableData({ columns: [], dataSource: [] }, '2');

              //清空质押券表内容
              this.props.clearPledgeBondInfo();

              //促发设置新增按钮disabled
              this.props.changeQuotationType('1');
              this.props.changeSettlementDate(null);

              //清空一些相关的公共参数
              resetFields([
                'productId',
                'portfolioId',
                'exchange',
                'quotationType',
                'orderSide',
                'agreementNumber',
                'repurchaseDays',
                'repoRate',
                'firstSettlemenDate',
                'settlementDate',
                'occupationDays',
                'counterParty',
                'counterPartyCode',
                'counterPartyper',
                'creator',
                'fee',
                'describe',
              ]);
            }
          });
        } else {
          let newOrderCategory = orderSide == '1' && fieldsValue.quotationType != '11' ? Number(fieldsValue.quotationType) + 5 + '' : fieldsValue.quotationType;
          const value1 = {
            pid: this.state.pid,
            portfolioId: fieldsValue.portfolioId,
            portfolioInfoId: fieldsValue.portfolioId,
            productId: fieldsValue.productId,
            type: 13,
            userId: localStorage.getItem('antd-pro-userId'),
            userName: user.currentUser.name,
            uid: this.state.uid,
            trade13: {
              portfolioId: fieldsValue.portfolioId,
              productId: fieldsValue.productId,
              exchange: fieldsValue.exchange,
              orderCategory: newOrderCategory,
              orderSide: orderSide,
              agreeCode: fieldsValue.agreementNumber,
              repurchaseDays: Number(fieldsValue.repurchaseDays),
              repoRate: fieldsValue.repoRate,
              firstSettlemenDate: moment(fieldsValue.firstSettlemenDate).format('YYYY-MM-DD'),
              settlementDate: moment(fieldsValue.settlementDate).format('YYYY-MM-DD'),
              occupationDays: Number(fieldsValue.occupationDays),
              counterParty: fieldsValue.counterParty,
              counterPartyCode: fieldsValue.counterPartyCode,
              counterPartyper: fieldsValue.counterPartyper,
              creator: fieldsValue.creator,
              pledgeVo: [...this.props.childData],
              investmentType: fieldsValue.investmentType,
              fee: 0, // 费用计算逻辑未完全梳理清楚，后续用户有真正需求时再添加费用计算相关逻辑     ,
              describe: fieldsValue.describe,
            },
          };
          if (confirmType == 'detail') {
            //二次确认数据 给父组件 进行弹窗 不请求后端
            tempObj = value1;
            return;
          }
          dispatch({
            type: 'exchangeAgreement/saveInstruction',
            payload: {
              ...value1,
            },
            callback: (data) => {
              const uid = uniqueKey();
              uid.then((r) => {
                this.setState({ uid: r });
              });
              if (data && data.success) {
                this.setState({
                  pid: '',
                  productGroupDisabled: false,
                  selfDisabledControl: {
                    //可选报价类型可编辑字段
                    productId: false, //产品
                    portfolioId: false, //组合
                    exchange: false, //交易所
                    quotationType: false, //报价类型
                    orderSide: false, //委托方向，所有类型都可以修改
                    agreementNumber: false, //约定号
                    repurchaseDays: false, //回购期限
                    repoRate: false, //回购利率
                    firstSettlemenDate: false, //首期结算日
                    counterParty: false, //交易对手
                    counterPartyCode: false, //交易对手编号
                    counterPartyper: false, //对手交易员
                    addPledge: false, //新增质押券
                    editPledge: false, //编辑质押券
                    deletePledge: false, //删除质押券
                    position: false, //持仓可点回填
                  },
                  bjlxData: dictionaryConfig.exchange.optionalQuotationType[0],
                });
                //关闭二次确认模态框
                this.props.onCancel();

                //清空资金
                this.props.getPortfolioId(undefined); //组合id为undefined 也抛出清空资金

                //清空持仓分析和在途回购信息
                this.props.getTableData({ columns: [], dataSource: [] }, '1');
                this.props.getTableData({ columns: [], dataSource: [] }, '2');

                //清空质押券表内容
                this.props.clearPledgeBondInfo();

                //促发设置新增按钮disabled
                this.props.changeQuotationType('1');
                this.props.changeSettlementDate(null);

                //清空一些相关的公共参数
                resetFields([
                  'productId',
                  'portfolioId',
                  'exchange',
                  'quotationType',
                  'orderSide',
                  'agreementNumber',
                  'repurchaseDays',
                  'repoRate',
                  'firstSettlemenDate',
                  'settlementDate',
                  'occupationDays',
                  'counterParty',
                  'counterPartyCode',
                  'counterPartyper',
                  'creator',
                  'describe',
                ]);
              }
            },
          });
        }
      },
    );
    return tempObj;
  };

  //指令下达
  save = () => {
    this.props.getPledgeBondInfo('1');
  };

  //取消
  cancel = () => {
    const {
      form: { resetFields },
    } = this.formGroupThis.props;
    if (this.props.tradeBook == '1') {
      this.props.rehandleSearch();
    }
    //解除loading
    this.setState({
      btnLoading: false,
    });
    //清空资金
    this.props.getPortfolioId(undefined); //组合id为undefined 也抛出清空资金
    // 设置为disable
    this.setState({
      disabled: true,
      exchangeDisabled: true,
      quotationTypeDisabled: true,
      productGroupDisabled: false,
      orderSideDisabled: false,
    });

    this.setState({
      pid: '',
      selfDisabledControl: {
        //可选报价类型可编辑字段
        productId: false, //产品
        portfolioId: false, //组合
        exchange: false, //交易所
        quotationType: false, //报价类型
        orderSide: false, //委托方向，所有类型都可以修改
        agreementNumber: false, //约定号
        repurchaseDays: false, //回购期限
        repoRate: false, //回购利率
        firstSettlemenDate: false, //首期结算日
        counterParty: false, //交易对手
        counterPartyCode: false, //交易对手编号
        counterPartyper: false, //对手交易员
        addPledge: false, //新增质押券
        editPledge: false, //编辑质押券
        deletePledge: false, //删除质押券
        position: false, //持仓可点回填
      },
      bjlxData: dictionaryConfig.exchange.optionalQuotationType[0],
    });

    //清空持仓分析和在途回购信息
    this.props.getTableData({ columns: [], dataSource: [] }, '1');
    this.props.getTableData({ columns: [], dataSource: [] }, '2');

    //清空质押券表内容
    this.props.clearPledgeBondInfo();

    //清空一些相关的公共参数
    resetFields([
      'productId',
      'portfolioId',
      'exchange',
      'quotationType',
      'orderSide',
      'agreementNumber',
      'repurchaseDays',
      'repoRate',
      'firstSettlemenDate',
      'settlementDate',
      'occupationDays',
      'counterParty',
      'counterPartyCode',
      'counterPartyper',
      'creator',
      'describe',
    ]);

    //促发设置新增按钮disabled
    this.props.changeQuotationType('1');
    this.props.changeSettlementDate(null);

    if (this.props.tradeBook == '1') {
      this.props.rehandleSearch2();
    }
  };

  trialOnClick = () => {
    this.props.getPledgeBondInfo('trail');
  };

  //试算按钮点击
  trialOnClicks = () => {
    const { dispatch, user } = this.props;
    const {
      form: { validateFields },
    } = this.formGroupThis.props;
    validateFields(
      [
        'productId',
        'portfolioId',
        'exchange',
        'quotationType',
        'orderSide',
        'agreementNumber',
        'repurchaseDays',
        'repoRate',
        'firstSettlemenDate',
        'settlementDate',
        'occupationDays',
        'counterParty',
        'counterPartyCode',
        'counterPartyper',
        'creator',
        'investmentType',
        'fee',
        'describe',
      ],
      (err, fieldsValue) => {
        if (err) return;
        if (this.props.childData == undefined || this.props.childData == null || this.props.childData.length == 0) {
          message.warning('请添加质押券信息');
          return;
        }
        let orderSide = '';
        if (fieldsValue.orderSide == '融资回购' || fieldsValue.orderSide == '2') {
          orderSide = '2';
          let endDate = moment(fieldsValue.settlementDate).format('YYYYMMDD');

          let flag = null;
          this.props.childData.map((item) => {
            if (item && item.dueDate && endDate >= moment(item.dueDate).format('YYYYMMDD') && this.props.tradeBook == '0') {
              message.warning('请确认当前质押券到期日要大于 "所有质押券信息表里质押券的回购到期结算日"!');

              flag = 1;
            }
          });

          if (flag == 1) {
            return;
          }
          //这边日期
        }
        if (fieldsValue.orderSide == '融券回购' || fieldsValue.orderSide == '1') {
          orderSide = '1';
        }
        if (moment(fieldsValue.firstSettlemenDate).format('YYYYMMDD') >= moment(fieldsValue.settlementDate).format('YYYYMMDD') && this.props.tradeBook == '0') {
          message.warning('请设置到期结算日晚于首期结算日');
          return;
        }

        // 指令下达时判断委托方向和可选报价类型是否匹配，指令下达时带确认的报价类型，需要转换
        let newOrderCategory1 = orderSide == '1' && fieldsValue.quotationType != '11' ? Number(fieldsValue.quotationType) + 5 + '' : fieldsValue.quotationType;

        const value = {
          pid: this.state.pid,
          portfolioId: fieldsValue.portfolioId,
          portfolioInfoId: fieldsValue.portfolioId,
          productId: fieldsValue.productId,
          type: 13,
          userId: localStorage.getItem('antd-pro-userId'),
          userName: user.currentUser.name,
          businessType: '13',
          productCode: this.state.productCode, //产品code
          portfolioCode: this.state.portfolioCode, //组合code
          tenant: user.currentUser.tenant, //租户code
          trade13: {
            portfolioId: fieldsValue.portfolioId,
            productId: fieldsValue.productId,
            exchange: fieldsValue.exchange,
            orderCategory: newOrderCategory1,
            orderSide: orderSide,
            agreeCode: fieldsValue.agreementNumber,
            repurchaseDays: Number(fieldsValue.repurchaseDays),
            repoRate: fieldsValue.repoRate,
            firstSettlemenDate: moment(fieldsValue.firstSettlemenDate).format('YYYY-MM-DD'),
            settlementDate: moment(fieldsValue.settlementDate).format('YYYY-MM-DD'),
            occupationDays: Number(fieldsValue.occupationDays),
            counterParty: fieldsValue.counterParty,
            counterPartyCode: fieldsValue.counterPartyCode,
            counterPartyper: fieldsValue.counterPartyper,
            creator: fieldsValue.creator,
            pledgeVo: [...this.props.childData],
            investmentType: fieldsValue.investmentType,
            describe: fieldsValue.describe,
          },
        };
        this.setState({ trailModel: true }, () => {
          dispatch({
            type: 'trailM/trialData',
            payload: value,
            callback: (res) => {
              if (res) {
                this.setState({
                  trailColumns: res.columns,
                  trailDataSource: res.dataSource,
                });
              } else {
                this.setState({
                  trailColumns: [],
                  trailDataSource: [],
                });
              }
            },
          });
        });
      },
    );
  };

  //试算结果列表优化
  trailColumnsChange = (data) => {
    if (data) {
      data?.map((item) => {
        if (item.key == 'ruleDesc') {
          item.ellipsis = true;
        } else {
          item.width = '125px';
        }
      });
    }
    return data;
  };
  //试算结果
  showTrail = () => {
    const { trailModel, trailColumns, trailDataSource } = this.state;
    const newTrailColumns = this.trailColumnsChange(trailColumns);
    return (
      <Modal
        visible={trailModel}
        title='试算结果'
        width={1200}
        onOk={() => {
          this.setState({ trailModel: false });
        }}
        onCancel={() => {
          this.setState({ trailModel: false });
        }}
      >
        <TableC
          columns={newTrailColumns}
          dataSource={trailDataSource}
          loading={this.props.loading.effects['trailM/trialData'] === true}
          scroll={{ y: '231px' }}
          rowKey='id'
          hidePage={true}
        />
      </Modal>
    );
  };
  //获取组合code
  portfolioCode = (e) => {
    if (e) {
      this.setState({ portfolioCode: e });
    } else this.setState({ portfolioCode: undefined });
  };
  //获取产品code
  productCode = (e) => {
    if (e) {
      this.setState({ productCode: e });
    } else this.setState({ productCode: undefined });
  };
  render() {
    const { user, type } = this.props;
    const { isZiGuan } = this.state;
    return (
      <div style={{paddingTop:'10px'}}>
        <FormGroup
          dataSource={[
            {
              title: ['产品', '组合'],
              dataIndex: ['productId', 'portfolioId'],
              type: DATA_ENTRY.PRODUCTGROUPSEP,
              disabled: this.state.productGroupDisabled || this.state.selfDisabledControl.productId,
              initialValue: [this.state.productId ? this.state.productId : undefined, this.state.portfolioId ? this.state.portfolioId : undefined],
              authority: 'write',
              multipleGroup: false,
              rules: [[{ required: true, message: '请选择产品' }], [{ required: true, message: '请选择组合' }]],
              groupOnChange: (e) => {
                this.groupOnChange(e);
                this.portfolioCode(e ? e.info.portfolioCode : undefined); //向外抛出组合code
                this.changeFee('portfolioid', e ? e.key : undefined);
              },
              productOnChange: (e) => {
                this.productCode(e ? e.info.portfolioCode : undefined); //向外抛出产品code
                this.changeFee('productId', e ? e.key : undefined);
              },
              allowClear: false,
              exist: 1,
              span: 24,
              tradeModel: type == 1 || type == 2 ? ['BOOKKEEPING_MODE', 'COMMAND_MODE'] : undefined, //不包含估值解析和估值对接的产品
            },
            ...(type != 10 && !isZiGuan
              ? [
                  {
                    title: '投资类型',
                    dataIndex: 'investmentType',
                    type: DATA_ENTRY.SELECT,
                    initialValue: this.state.formItem.investmentType ? this.state.formItem.investmentType : 'AC',
                    disabled: type == 1 || type == 11 || type == 2 ? false : true,
                    dataSource: investmentTypeData,
                    allowClear: true,
                    rules: [{ required: false, message: '请选择' }],
                    onChange: (e) => this.props.investmentChange(e),
                    span: 12,
                  },
                ]
              : []),
            {
              title: '交易市场',
              dataIndex: 'exchange',
              type: DATA_ENTRY.TRADINGMARKET,
              initialValue: this.state.formItem.exchange ? this.state.formItem.exchange : '101',
              rules: [{ required: true, message: '请选择交易所' }],
              onChange: (e) => {
                // this.jysOnChange(e)
                // this.changeFee('exchangecode', e ? e.value : '101')
              },
              // disabled: this.state.exchangeDisabled || this.state.selfDisabledControl.exchange,
              disabled: true,
              span: 12,
              onRef: (ref) => (this.formGroupThis = ref),
            },
            {
              title: '报价类型',
              dataIndex: 'quotationType',
              type: DATA_ENTRY.SELECT,
              dataSource: this.props.tradeBook == '0' ? this.state.bjlxData : this.props.tradeBook == '1' ? this.state.bjlxData2 : dictionaryConfig.exchange.shanghaiExchange,
              rules: [{ required: true, message: '请选择报价类型' }],
              initialValue: this.state.formItem.orderCategory || '1',
              disabled: this.state.quotationTypeDisabled || this.state.selfDisabledControl.quotationType,
              onChange: (e) => {
                this.bjlxOnChange(e);
              },
              span: 12,
            },
            {
              title: '委托方向',
              dataIndex: 'orderSide',
              type: DATA_ENTRY.SELECT,
              dataSource: dictionaryConfig.orderSide,
              rules: [{ required: true, message: '请选择委托方向' }],
              initialValue: this.state.formItem.orderSide,
              disabled: this.state.disabled || this.state.orderSideDisabled || this.state.selfDisabledControl.orderSide,
              onChange: (e) => {
                this.wtfxOnChange(e);
                this.changeFee('orderside', e);
              },
              span: 12,
            },
            {
              title: '约定号',
              dataIndex: 'agreementNumber',
              type: DATA_ENTRY.INPUT,
              rules: [{ required: this.state.agreeCodeRules, message: '请输入约定号' }],
              initialValue: this.state.formItem.agreeCode,
              disabled: this.state.disabled || this.state.selfDisabledControl.agreementNumber,
              span: 12,
            },
            {
              title: '回购期限',
              dataIndex: 'repurchaseDays',
              type: DATA_ENTRY.INPUT,
              rules: [
                { required: true, message: '请输入回购期限' },
                { pattern: /^([1-9]|[1-9][0-9]|[1-2][0-9][0-9]|[3][0-5][0-9]|(360|361|363|362|364|365))$/, message: '必须为不大于365的正整数' },
              ],
              initialValue: this.state.formItem.repurchaseDays,
              disabled: this.state.disabled || this.state.selfDisabledControl.repurchaseDays,
              onBlur: (e) => {
                this.hgqxOnChange(e);
              },
              validateTrigger: 'onBlur',
              suffix: '天',
              span: 12,
            },
            {
              title: '回购利率(%)',
              dataIndex: 'repoRate',
              type: DATA_ENTRY.INPUTNUMBER,
              rules: [
                { required: true, message: '请输入回购利率' },
                { pattern: /^(0\.0*[1-9]+[0-9]*$|[1-9]+[0-9]*\.[0-9]*[0-9]$|[1-9]+[0-9]*$)/, message: '回购利率必须大于0' },
              ],
              initialValue: this.state.formItem.repoRate,
              validateTrigger: 'onBlur',
              disabled: this.state.disabled || this.state.selfDisabledControl.repoRate,
              precision: 3,
              formatter: (inValue) => fixedNum(inValue),
              onChange: (e) => this.changeRepoRate(e),
              parser: (inValue) => inValue.replace(/\$\s?|(,*)/g, ''),
              span: 12,
            },
            {
              title: '首期结算日',
              type: DATA_ENTRY.SINGLEDATE,
              dataIndex: 'firstSettlemenDate',
              initialValue: this.state.formItem.firstSettlemenDate ? moment(this.state.formItem.firstSettlemenDate) : moment(new Date()),
              rules: [{ required: true, message: '请选择首期结算日' }],
              disabled: true,
              onChange: (e) => this.sqjsrOnChange(e),
              span: 12,
            },
            {
              title: '到期结算日',
              type: DATA_ENTRY.SINGLEDATE,
              dataIndex: 'settlementDate',
              initialValue: this.state.formItem.settlementDate ? moment(this.state.formItem.settlementDate) : null,
              rules: [{ required: true, message: '请选择到期结算日' }],
              disabled: this.state.settlementDateDisabled,
              onChange: (e) => this.dqjsrOnChange(e),
              span: 12,
            },
            {
              title: '实际占款天数',
              dataIndex: 'occupationDays',
              type: DATA_ENTRY.INPUT,
              initialValue: this.state.formItem.occupationDays,
              rules: [
                { required: true, message: '请输入实际占款天数' },
                { pattern: /^\+?[1-9]\d*$/, message: '实际占款天数必须为正整数' },
              ],
              validateTrigger: 'onBlur',
              disabled: this.state.occupationDaysDisabled,
              suffix: '天',
              span: 12,
            },
            {
              // 交易对手
              dataIndex: 'counterParty',
              type: DATA_ENTRY.TRADINGCOMPANY,
              initialValue: this.state.formItem.counterParty,
              multiple: false,
              disabled: this.state.disabled || this.state.selfDisabledControl.counterParty,
              placeholder: '请选择',
              rules: [{ required: true, message: '请选择交易对手' }],
              onRef: (ref) => (this.Company = ref),
              span: 12,
              scenesType: type, //组件场景类型，用于详情时根据ID回填值
            },
            {
              title: '交易对手编码',
              dataIndex: 'counterPartyCode',
              type: DATA_ENTRY.INPUT,
              initialValue: this.state.formItem.counterPartyCode,
              rules: [{ required: true, message: '请输入交易对手编码' }],
              disabled: this.state.disabled || this.state.selfDisabledControl.counterPartyCode,
              span: 12,
            },
            {
              title: '对手交易员',
              dataIndex: 'counterPartyper',
              type: DATA_ENTRY.INPUT,
              initialValue: this.state.formItem.counterPartyper,
              rules: [{ required: true, message: '请输入对手交易员' }],
              disabled: this.state.disabled || this.state.selfDisabledControl.counterPartyper,
              span: 12,
            },
            {
              title: '下达人',
              dataIndex: 'creator',
              type: DATA_ENTRY.INPUT,
              initialValue: this.state.formItem.creator ? this.state.formItem.creator : user.currentUser.name,
              rules: [{ required: true, message: '请输入下达人' }],
              disabled: true,
              span: 12,
            },
            // {
            //     title: '费用',
            //     dataIndex: 'fee',
            //     placeholder: "请输入",
            //     type: DATA_ENTRY.INPUTNUMBER,
            //     min: 0,
            //     precision: 2,
            //     initialValue: this.state.formItem.fee,
            //     splitStyle: true,
            //     disabled: (type == 1 || type == 11 || type == 2) ? false : true,
            //     unit: '元',
            // }
            {
              dataIndex: 'describe',
              type: DATA_ENTRY.INPUT,
              title: '备注',
              disabled: type == 1 || type == 11 || type == 2 ? false : true,
              initialValue: this.state.formItem.describe ? this.state.formItem.describe : undefined,
              placeholder: '请输入',
              showTextArea: true,
              autosize: { minRows: 2, maxRows: 2 },
              span: 24,
            },
          ]}
          autoLayout={false}
        />
        {this.props.tradeBook ? (
          <div style={{ paddingBottom: '8px', float: 'right', paddingRight: '27px' }}>
            {/* {type == "2" && <PrimaryC
                        loading={this.props.loading.effects['trailM/trialData'] === true}
                        onClick={() => this.trialOnClick()}
                        title={'试算'}
                        style={{ marginRight: "10px" }}
                    />} */}
            <PrimaryC
              title={this.props.type == 2 || this.props.type == 11 ? '确定' : this.props.tradeInfo ? '保存' : '下达'}
              loading={this.state.btnLoading}
              style={{ margin: '10px' }}
              onClick={() => this.save()}
            />
            <PrimaryGhostC title='取消' style={{ margin: '10px' }} onClick={() => this.cancel()} />
          </div>
        ) : null}
        {this.state.trailModel && this.showTrail()}
      </div>
    );
  }
}
